using UnityEngine;
using System.Collections;
using System.Collections.Generic;

/**
 * Caches filename->images for the GUI
 * The reason is that Resources.Load is slow
 */
public class GuiImages : MonoBehaviour {
	Dictionary<string, Texture2D> images;
	
	void Awake () {
		this.images = new Dictionary<string, Texture2D>();
	}
	
	public Texture2D GetTexture(string path) {
		Texture2D t;
		
		if (this.images.ContainsKey(path)) {
			t = this.images[path];
		} else {
			t = (Texture2D)Resources.Load(path);
			if (t != null) {
				this.images[path] = t;
			}
		}
		
		return t;
	}
}
	
